package com.karaoke.android.kege.fragment


import android.os.Bundle
import android.support.v4.app.Fragment
import android.transition.Explode
import android.transition.Transition
import android.view.Menu
import android.view.MenuInflater
import com.apkfuns.logutils.LogUtils
import com.karaoke.android.kege.BR
import com.karaoke.android.kege.InputType
import com.karaoke.android.kege.R
import com.karaoke.android.kege.databinding.FragmentSearchBinding
import com.karaoke.android.kege.inputType
import com.karaoke.android.kege.vm.SearchViewModel
import com.karaoke.android.library.mvvm.BindingConfig


/**
 * A simple [Fragment] subclass.
 */
class SearchFragment : BaseFragment<SearchViewModel>()
{
    override val viewModel: SearchViewModel by lazy { SearchViewModel(this) }
    override val config: BindingConfig by lazy { BindingConfig(R.layout.fragment_search, BR.viewModel) }


    override fun onInitLoad()
    {
        LogUtils.e("onInitLoad")
        val mBinding = dataBinding as FragmentSearchBinding
        when (inputType)
        {
            InputType.PIN_YIN  -> mBinding.langTab.check(R.id.rbPinYIn)
            InputType.SHOW_XIE -> mBinding.langTab.check(R.id.rbShowXie)
            else               ->
            {
            }
        }
        mBinding.searchType.check(R.id.rbAll)
    }

    override fun getEnterTransition(): Transition = Explode().apply { duration = 200 }

    override fun onCreate(savedInstanceState: Bundle?)
    {
        super.onCreate(savedInstanceState)
        this.title = "搜索"
        setHasOptionsMenu(true)

    }

    override fun onCreateOptionsMenu(menu: Menu?, inflater: MenuInflater?)
    {
        super.onCreateOptionsMenu(menu, inflater)
    }

    override fun onSaveInstanceState(outState: Bundle?)
    {
        super.onSaveInstanceState(outState)
    }
}
